package com.wd.mine.activity

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentPagerAdapter
import com.wd.common.base.BaseActivity
import com.wd.mine.R
import com.wd.mine.databinding.ActivityCollection1Binding
import com.wd.mine.databinding.ActivityCollectionBinding
import com.wd.mine.fragment.OldCarListFragment
import com.wd.mine.fragment.WenZhangFragment

class CollectionAActivity : BaseActivity<ActivityCollection1Binding, Any>() {

    override fun getViewBinding(): ActivityCollection1Binding =ActivityCollection1Binding.inflate(layoutInflater)
    private val title = arrayOf("收藏")
    override fun initData() {
        val fragments = ArrayList<Fragment>()
        fragments.add(OldCarListFragment())
        binding.oldviewpageid.offscreenPageLimit=2

        binding.oldviewpageid.adapter = object : FragmentPagerAdapter(supportFragmentManager) {
            override fun getItem(position: Int): Fragment {
                return fragments[position]
            }

            override fun getCount(): Int {
                return fragments.size
            }

            override fun getPageTitle(position: Int): CharSequence? {
                return title[position]
            }
        }
        //指示器颜色
        binding.oldtabid.setSelectedTabIndicatorColor(resources.getColor(android.R.color.white))
        binding.oldtabid.setupWithViewPager(binding.oldviewpageid)
        binding.oldtabid.getTabAt(0)?.select()
    }

    override fun onDestroy() {
        super.onDestroy()
        binding.oldviewpageid.removeAllViews()
    }
}